package com.chen.oss.config;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * minio配置管理
 */
@Configuration
@Data
@ConfigurationProperties("minio")
public class MinioConfig {
    /**
     * minioUrl
     */
    private String url;

    /**
     * minio账户
     */
    private String accessKey;

    /**
     * minio密码
     */
    private String secretKey;

    /**
     * 构造minioClient
     */
    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                .endpoint(url)
                .credentials(accessKey, secretKey)
                .build();
    }
}
